﻿<!-- #Include File="../../Include/Function.asp" -->
<!-- #Include File="../../Include/Channel.asp" -->
<!-- #Include File="../../Include/FileSys.asp" -->
<!--#include file="Upfile.asp"-->
<!--#include file="Draw.asp"-->
<%
Private Function getjson(byval t0,byval t1,byval t2,byval t3)
	Response.AddHeader "Content-Type", "text/plain"
	if t0=0 Then
		Response.Write "{""url"":"""",""original"":"""",""title"":"""",""state"":"""&t3&"""}"
	else
		Response.Write "{""url"":"""&t1&""",""original"":"""&t2&""",""title"":"""&t2&""",""state"":"""&t3&"""}"
	end if
End Function

Function get_uploaderr(byval t0)
	dim t1:t1=""
	select case t0
		case -1:t1="没有文件上传"
		case 1:t1="文件过大，上传失败"
		case 2:t1="不允许被上传的文件"
		case 3:t1="文件过大，且不允许被上传"
		case 4:t1="文件保存失败"
		case 5:t1="禁止上传此类文件"
	end select
	get_uploaderr=t1
End Function

Private Function adddb(byval t0,byval t1,byval t2,byval t3,byval t4,byval t5,byval t6,byval t7,byval t8,byval t9,byval t10)
	ID = GetNewID("Attachment", "ID")
	insert "Attachment",array(array("ID",ID,0,0),array("ChannelID",t10,0,0),array("classid",t9,0,0),array("cid",t8,0,0),array("filepath",t0,255,1),array("filename",t1,255,1),array("filesize",getnum(t2),255,1),array("oldname",Replace(t3, "."&t4, "", 1, -1, 1),255,1),array("fileext",t4,50,1),array("ispic",Is_Pic("."&t4),1,0),array("createip",getip,255,1),array("createdate",t5,255,0),array("adminid",t6,0,0),array("userid",t7,0,0),array("fullname",t0&t1,0,1))
	if Is_Pic(t1)=1 then
		dim draw
		set draw=new cms_draw
		draw.add t0&t1
		set draw=nothing
	end if
End Function

Private Function listdb()
	Response.AddHeader "Content-Type", "text/plain"
	dim AdminID
	AdminID = Session_Get(Session_For&"AdminID")
	if AdminID = "" then
		getjson 0,"","","登录失败"
		Exit Function
	end if
	start = Code_CLng(Request.QueryString("start"))
	size = Code_CLng(Request.QueryString("size"))
	total = 0

	If size <= 0 Then
		size = Code_CLng(20)
	End If

	listTemplateName = Session.Value("ueditor_asp_listTemplateName")
	ChannelID = Code_CLng(Trim(Request.QueryString("channelid")))
	If ChannelID = "" Then ChannelID = 0
	If ChannelID > 0 Then
		Call GetChannel(ChannelID)
		select case listTemplateName
			case "video"
				extensions=ChannelUpFileType(2)
			case "file"
				extensions=ChannelUpFileType(3)
			case else
				extensions=ChannelUpFileType(0)
		end select
	Else
		select case listTemplateName
			case "video"
				extensions=UploadSetting(22)
			case "file"
				extensions=UploadSetting(23)
			case else
				extensions=UploadSetting(3)
		end select
	End If
	extensions = Split(extensions,"|")
	for i = 0 to ubound(extensions)
		If i = 0 Then
			fileext = fileext & "'" & extensions(i) & "'"
		Else
			fileext = fileext & "," & "'" & extensions(i) & "'"
		End If
	next
	Sql = "Select * From [{prefix}Attachment] where fileext in ("&fileext&")"
	If ChannelID<>0 Then
		Sql = Sql & " And ChannelID=" & ChannelID & ""
	End If
	If AdminID<>"" Then
		Sql = Sql & " And adminid=" & AdminID & ""
	End If
	Sql = Sql & " Order By ID Desc"
	Call Exe_Conn(Rs,Sql,1)
	If Rs.BOF And Rs.EOF Then
	Else
		total = Rs.RecordCount
		index = 0
		Do While Not Rs.Eof
			If index >= start And index < start + size Then
				If index = 0 Then
					list = list & "{""url"":"""&Rs("fullname")&"""}"
				Else
					list = list & ",{""url"":"""&Rs("fullname")&"""}"
				End If
			End If
			index = index + 1
			Rs.MoveNext
		Loop
		Rs.Close
		state = "SUCCESS"
	End If
	Response.Write "{""state"": """&state&""",""list"": ["&Replace(list, "/", "\/", 1, -1, 1)&"],""start"": "&start&",""size"": "&size&",""total"": "&total&"}"
End Function

Private Function listdbsss()
	Response.AddHeader "Content-Type", "text/plain"
	dim AdminID
	AdminID = Session_Get(Session_For&"AdminID")
	if AdminID = "" then
		getjson 0,"","","登录失败"
		Exit Function
	end if
	start = Code_CLng(Request.QueryString("start"))
	size = Code_CLng(Request.QueryString("size"))
	total = 0

	If size <= 0 Then
		size = Code_CLng(20)
	End If
	
	ChannelID = Trim(Request.QueryString("channelid"))
	If ChannelID = "" Then ChannelID = 0
	If ChannelID > 0 Then
		Call GetChannel(ChannelID)
		UploadList = LCase(InstallDir & UploadSetting(1) & "/" & Trim(ChannelUploadDir))
	Else
		UploadList = LCase(InstallDir & UploadSetting(1) & "/UEditor")
	End If

	Set Fso = Server.CreateObject(Fso_Sys)
	If fso.FolderExists(Server.MapPath(UploadList)) = False Then
		state = "找不到目录：" + UploadList
	Else
		Set all = ListAllFilesInFolder( fso, UploadList )
		total = all.Count
		index = 0
		For Each file in all
			If index >= start And index < start + size Then
				If index = 0 Then
					list = list & "{""url"":"""&file&"""}"
				Else
					list = list & ",{""url"":"""&file&"""}"
				End If
			End If
			index = index + 1
		Next
		state = "SUCCESS"
	End If

	Response.Write "{""state"": """&state&""",""list"": ["&Replace(list, "/", "\/", 1, -1, 1)&"],""start"": "&start&",""size"": "&size&",""total"": "&total&"}"
End Function

Function ListAllFilesInFolder( fso, path )
	Dim list
	Set list = Server.CreateObject("Scripting.Dictionary")
	Set folder = fso.GetFolder(Server.MapPath(path))
	For Each file In folder.Files
		If CheckExt(file.Name) Then
			list.Add path & "/" & file.Name, true
		End If
	Next
	For Each subFolder In folder.SubFolders
		Set subList = ListAllFilesInFolder( fso, path & "/" & subFolder.Name )
		For Each subListFile In subList
			list.Add subListFile, true
		Next
	Next
	Set ListAllFilesInFolder = list
End Function

Function CheckExt( filename )
	listTemplateName = Session.Value("ueditor_asp_listTemplateName")
	ChannelID = Trim(Request.QueryString("channelid"))
	If ChannelID = "" Then ChannelID = 0
	If ChannelID > 0 Then
		Call GetChannel(ChannelID)
		select case listTemplateName
			case "video"
				extensions=ChannelUpFileType(2)
			case "file"
				extensions=ChannelUpFileType(3)
			case else
				extensions=ChannelUpFileType(0)
		end select
	Else
		select case listTemplateName
			case "video"
				extensions=UploadSetting(22)
			case "file"
				extensions=UploadSetting(23)
			case else
				extensions=UploadSetting(3)
		end select
	End If
	extensions = Split(extensions,"|")
	For i = Lbound(extensions) to Ubound(extensions)
		If UCase(GetExt(filename)) = UCase("."&extensions(i)) Then
			CheckExt = true
			Exit Function
		End If
	Next
	CheckExt = false
End Function

Function GetExt( file )
	GetExt = Right( file, Len(file) - InStrRev(file, ".") + 1 )
End Function

Private Function editordb()
	dim AdminID, sqlAuth, rsAuth
	AdminID = Session_Get(Session_For&"AdminID")
	if AdminID = "" then
		getjson 0,"","","登录失败"
		Exit Function
	end if
	sqlAuth = "Select AuthID From Admin_Auth Where href='UploadFile/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
	if UploadSetting(0)=999 Then
		getjson 0,"","","系统未开放文件上传功能。"
		Exit Function
	end if
	dim sqltime:sqltime="now()"
	if SystemDatabaseType = 1 then sqltime="GetDate()"
	dim ChannelID,classid,cid
	ChannelID = Code_CLng(Trim(Request.QueryString("channelid")))
	classid=Code_CLng(Trim(Request.QueryString("classid")))
	cid=Code_CLng(Trim(Request.QueryString("cid")))
	If ChannelID = "" Then ChannelID = 0
	If ChannelID > 0 Then
		Call GetChannel(ChannelID)
		IsAutoSort=Get_ChannelSetup(ChannelSetup,16)
		MaxFileSize=ChannelMaxFileSize
		UploadDir = InstallDir & UploadSetting(1) & "/" & Trim(ChannelUploadDir) & "/"
		If IsAutoSort=1 Then
			UploadDir = CreatePath(UploadDir) '按年月栏目目录
		End If
	Else
		MaxFileSize=UploadSetting(21)
		UploadDir = InstallDir & UploadSetting(1) & "/UEditor/"
		UploadDir = CreatePath(UploadDir) '按年月栏目目录
	End If
	dim upload
	set upload=new upload
	If ChannelID > 0 Then
		select case action
			case "video"
				upload.filetype=ChannelUpFileType(2)
			case "file"
				upload.filetype=ChannelUpFileType(3)
			case else
				upload.filetype=ChannelUpFileType(0)
		end select
	Else
		select case action
			case "video"
				extensions=UploadSetting(22)
			case "file"
				extensions=UploadSetting(23)
			case else
				upload.filetype=UploadSetting(3)
		end select
	End If
	upload.savepath=UploadDir
	upload.charset="utf-8"
	upload.maxsize=MaxFileSize
	upload.autosave=0
	upload.open()
	dim i,filepath,filenew,filename,filesize,oldname,fileext,errstr
	for i=1 to ubound(upload.fileitem)
		filepath=upload.savepath
		filenew=upload.form(upload.fileitem(i))
		filename=lcase(filepath&filenew)
		Call Tmp_Upload(filepath,filenew,1)
		filesize=upload.form(upload.fileitem(i)&"_size")/1024
		fileext=upload.form(upload.fileitem(i)&"_ext")
		oldname=upload.form(upload.fileitem(i)&"_name")
		errstr=get_uploaderr(upload.form(upload.fileitem(i)&"_Err"))
		if len(errstr)>0 then
			getjson 0,"","",errstr
		else
			getjson 1,filename,Replace(oldname, "."&fileext, "", 1, -1, 1),"SUCCESS"
			adddb filepath,filenew,filesize,oldname,fileext,sqltime,AdminID,0,cid,classid,ChannelID
		end if
	next
	set upload=nothing
End Function

Private Function swfdb()
	dim AdminID, sqlAuth, rsAuth
	AdminID = Session_Get(Session_For&"AdminID")
	if AdminID = "" then
		Response.Write "{""error"":""登录失败""}"
		Exit Function
	end if
	sqlAuth = "Select AuthID From Admin_Auth Where href='UploadFile/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
	if UploadSetting(0)=999 Then
		Response.Write "{""error"":""系统未开放文件上传功能。""}"
		Exit Function
	end if
	dim sqltime:sqltime="now()"
	if SystemDatabaseType = 1 then sqltime="GetDate()"
	dim ChannelID,classid,cid
	ChannelID = Code_CLng(Trim(Request.QueryString("channelid")))
	classid=Code_CLng(Trim(Request.QueryString("classid")))
	cid=Code_CLng(Trim(Request.QueryString("cid")))
	If ChannelID = "" Then ChannelID = 0
	dim upload,filetype,uptype
	filetype=Code_CLng(trim(request.querystring("filetype")))
	If ChannelID > 0 Then
		Call GetChannel(ChannelID)
		IsAutoSort=Get_ChannelSetup(ChannelSetup,16)
		MaxFileSize=ChannelMaxFileSize
		UploadDir = InstallDir & UploadSetting(1) & "/" & Trim(ChannelUploadDir) & "/"
		If IsAutoSort=1 Then
			UploadDir = CreatePath(UploadDir) '按年月栏目目录
		End If
		MaxFileSize=ChannelMaxFileSize
		select case filetype
			case "2":uptype=ChannelUpFileType(3)
			case "3":uptype=ChannelUpFileType(2)
			case "4":uptype="gif|jpg|png|bmp|flv|mp4|swf|mp3|rar|zip|tar|gz|7z|bz2|cab|iso|apk|doc|docx|xls|xlsx|ppt|pptx|pdf|txt|md|xml"
			case "5":uptype=ChannelUpFileType(1)
			case else:uptype=ChannelUpFileType(0)
		end select
	Else
		MaxFileSize=UploadSetting(21)
		UploadDir = InstallDir & UploadSetting(1) & "/UEditor/"
		UploadDir = CreatePath(UploadDir) '按年月栏目目录
		select case filetype
			case "2":uptype=UploadSetting(23)
			case "3":uptype=UploadSetting(22)
			case "4":uptype="gif|jpg|png|bmp|flv|mp4|swf|mp3|rar|zip|tar|gz|7z|bz2|cab|iso|apk|doc|docx|xls|xlsx|ppt|pptx|pdf|txt|md|xml"
			case "5":uptype="swf"
			case else:uptype=UploadSetting(3)
		end select
	End If
	set upload=new upload
		upload.filetype=uptype
		upload.savepath=UploadDir
		upload.charset="utf-8"
		upload.maxsize=MaxFileSize
		upload.autosave=0
		upload.open()
		dim i,filepath,filenew,filename,filesize,oldname,fileext,errstr
		for i=1 to ubound(upload.fileitem)
			filepath=upload.savepath
			filenew=upload.form(upload.fileitem(i))
			filename=filepath&filenew
			Call Tmp_Upload(filepath,filenew,0)
			filesize=upload.form(upload.fileitem(i)&"_size")/1024
			fileext=upload.form(upload.fileitem(i)&"_ext")
			oldname=upload.form(upload.fileitem(i)&"_name")
			errstr=get_uploaderr(upload.form(upload.fileitem(i)&"_Err"))
			if len(errstr)>0 then
				Response.Write "{""error"":"""&errstr&"""}"
			else
				adddb filepath,filenew,filesize,oldname,fileext,sqltime,AdminID,0,cid,classid,ChannelID
				Response.Write "{""fileurl"":"""&filename&""",""oldname"":"""&Replace(oldname, "."&fileext, "", 1, -1, 1)&""",""filesize"":"""&getnum(filesize)&"""}"
			end if
		next
	set upload=nothing
End Function

Private Function templatedb()
	dim AdminID, sqlAuth, rsAuth
	AdminID = Session_Get(Session_For&"AdminID")
	if AdminID = "" then
		Response.Write "{""result"":""0"",""info"":""登录失败""}"
		Exit Function
	end if
	sqlAuth = "Select AuthID From Admin_Auth Where href='UploadFile/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
	if UploadSetting(0)=999 Then
		Response.Write "{""result"":""0"",""info"":""系统未开放文件上传功能。""}"
		Exit Function
	end if
	dim upload
	MaxFileSize=UploadSetting(21)
	UploadDir = InstallDir & "Skin/Images/"
	set upload=new upload
		upload.filetype=UploadSetting(3)
		upload.savepath=UploadDir
		upload.charset="utf-8"
		upload.maxsize=MaxFileSize
		upload.autosave=0
		upload.open()
		dim i,filepath,filenew,filename,filesize,oldname,fileext,errstr
		for i=1 to ubound(upload.fileitem)
			filepath=upload.savepath
			filenew=upload.form(upload.fileitem(i))
			filename=filepath&filenew
			Call Tmp_Upload(filepath,filenew,0)
			filesize=upload.form(upload.fileitem(i)&"_size")/1024
			fileext=upload.form(upload.fileitem(i)&"_ext")
			oldname=upload.form(upload.fileitem(i)&"_name")
			errstr=get_uploaderr(upload.form(upload.fileitem(i)&"_Err"))
			if len(errstr)>0 then
				Response.Write "{""result"":""0"",""info"":"""&errstr&"""}"
			else
				Response.Write "{""result"":""1"",""info"":""\u4e0a\u4f20\u6210\u529f\uff01"",""url"":"""&filename&""",""oldname"":"""&Replace(oldname, "."&fileext, "", 1, -1, 1)&""",""filesize"":"""&getnum(filesize)&"""}"
			end if
		next
	set upload=nothing
End Function

Private Function config()
	dim AdminID
	AdminID = Session_Get(Session_For&"AdminID")
	if AdminID = "" then
		Exit Function
	end if
	Response.AddHeader "Content-Type", "text/plain"
	dim html:html=""
	html=html&"{"&vbcrlf
	html=html&"    ""imageActionName"": ""image"","&vbcrlf
	html=html&"    ""imageFieldName"": ""upfile"","&vbcrlf
	html=html&"    ""imageMaxSize"": "&2048*1000&","&vbcrlf
	html=html&"    ""imageAllowFiles"": ["".png"", "".jpg"", "".gif"", "".bmp""],"&vbcrlf
	html=html&"    ""imageCompressEnable"": true,"&vbcrlf
	html=html&"    ""imageCompressBorder"": 600,"&vbcrlf
	html=html&"    ""imageInsertAlign"": ""none"","&vbcrlf
	html=html&"    ""imageUrlPrefix"": """","&vbcrlf
	html=html&"    ""imagePathFormat"": """","&vbcrlf
	html=html&"    ""scrawlActionName"": ""uploadscrawl"","&vbcrlf
	html=html&"    ""scrawlFieldName"": ""upfile"","&vbcrlf
	html=html&"    ""scrawlPathFormat"": """","&vbcrlf
	html=html&"    ""scrawlMaxSize"": "&2048*1000&","&vbcrlf
	html=html&"    ""scrawlUrlPrefix"": """","&vbcrlf
	html=html&"    ""scrawlInsertAlign"": ""none"","&vbcrlf
	html=html&"    ""snapscreenActionName"": ""uploadsnapscreen"","&vbcrlf
	html=html&"    ""snapscreenFieldName"": ""upfile"","&vbcrlf
	html=html&"    ""snapscreenMaxSize"": "&2048*1000&","&vbcrlf
	html=html&"    ""snapscreenAllowFiles"": ["".png"", "".jpg"", "".jpeg"", "".gif"", "".bmp""],"&vbcrlf
	html=html&"    ""snapscreenCompressEnable"": true,"&vbcrlf
	html=html&"    ""snapscreenCompressBorder"": 600,"&vbcrlf
	html=html&"    ""snapscreenInsertAlign"": ""none"","&vbcrlf
	html=html&"    ""snapscreenUrlPrefix"": """","&vbcrlf
	html=html&"    ""snapscreenPathFormat"": """","&vbcrlf
	html=html&"    ""catcherLocalDomain"": ["&vbcrlf
	html=html&"        ""127.0.0.1"","&vbcrlf
	html=html&"        ""localhost"","&vbcrlf
	html=html&"        ""img.baidu.com"""&vbcrlf
	html=html&"    ],"&vbcrlf
	html=html&"    ""catcherActionName"": ""catchimage"","&vbcrlf
	html=html&"    ""catcherFieldName"": ""source"","&vbcrlf
	html=html&"    ""catcherPathFormat"": """","&vbcrlf
	html=html&"    ""catcherUrlPrefix"": """","&vbcrlf
	html=html&"    ""catcherMaxSize"": "&2048*1000&","&vbcrlf
	html=html&"    ""catcherAllowFiles"": ["".png"","".jpg"","".jpeg"","".gif"","".bmp""],"&vbcrlf
	html=html&"    ""videoActionName"": ""video"","&vbcrlf
	html=html&"    ""videoFieldName"": ""upfile"","&vbcrlf
	html=html&"    ""videoPathFormat"": """","&vbcrlf
	html=html&"    ""videoUrlPrefix"": """","&vbcrlf
	html=html&"    ""videoMaxSize"": "&2048*1000&","&vbcrlf
	html=html&"    ""videoAllowFiles"": ["&vbcrlf
	html=html&"        "".flv"","".swf"","".mkv"","".avi"","".rm"","".rmvb"","&vbcrlf
	html=html&"        "".mpeg"","".mpg"","".ogg"","".ogv"","".mov"","".wmv"","&vbcrlf
	html=html&"        "".mp4"","".webm"","".mp3"","".wav"","".mid"""&vbcrlf
	html=html&"    ],"&vbcrlf
	html=html&"    ""fileActionName"": ""file"","&vbcrlf
	html=html&"    ""fileFieldName"": ""upfile"","&vbcrlf
	html=html&"    ""filePathFormat"": """","&vbcrlf
	html=html&"    ""fileUrlPrefix"": """","&vbcrlf
	html=html&"    ""fileMaxSize"": "&2048*1000&","&vbcrlf
	html=html&"    ""fileAllowFiles"": ["&vbcrlf
	html=html&"        "".png"", "".jpg"", "".gif"", "".bmp"","&vbcrlf
	html=html&"        "".flv"", "".swf"", "".mp3"", "".mp4"","&vbcrlf
	html=html&"        "".rar"", "".zip"", "".tar"", "".gz"", "".7z"", "".bz2"", "".cab"", "".iso"","&vbcrlf
	html=html&"        "".doc"", "".docx"", "".xls"", "".xlsx"", "".ppt"", "".pptx"", "".pdf"", "".txt"", "".md"", "".xml"""&vbcrlf
	html=html&"    ],"&vbcrlf
	html=html&"    ""imageManagerActionName"": ""listimage"","&vbcrlf
	html=html&"    ""imageManagerListPath"": """","&vbcrlf
	html=html&"    ""imageManagerListSize"": 20,"&vbcrlf
	html=html&"    ""imageManagerUrlPrefix"": """","&vbcrlf
	html=html&"    ""imageManagerInsertAlign"": ""none"","&vbcrlf
	html=html&"    ""imageManagerAllowFiles"": ["".png"","".jpg"","".jpeg"","".gif"","".bmp""],"&vbcrlf
	html=html&"    ""fileManagerActionName"": ""listfile"","&vbcrlf
	html=html&"    ""fileManagerListPath"": """","&vbcrlf
	html=html&"    ""fileManagerUrlPrefix"": """","&vbcrlf
	html=html&"    ""fileManagerListSize"": 20,"&vbcrlf
	html=html&"    ""fileManagerAllowFiles"": ["&vbcrlf
	html=html&"        "".png"","".jpg"","".jpeg"","".gif"","".bmp"","&vbcrlf
	html=html&"        "".flv"","".swf"","".mkv"","".avi"","".rm"","".rmvb"","&vbcrlf
	html=html&"        "".mpeg"","".mpg"","".ogg"","".ogv"","".mov"","".wmv"","".mp4"","&vbcrlf
	html=html&"        "".webm"","".mp3"","".wav"","".mid"","".rar"","".zip"","".tar"","&vbcrlf
	html=html&"        "".gz"","".7z"","".bz2"","".cab"","".iso"","&vbcrlf
	html=html&"        "".doc"","".docx"","".xls"","".xlsx"","".ppt"","".pptx"","&vbcrlf
	html=html&"        "".pdf"","".txt"","".md"","".xml"""&vbcrlf
	html=html&"    ]"&vbcrlf
	html=html&"}"
	Response.Write html
End Function

'按月份自动明名上传文件夹,需要ＦＳＯ组件支持。
Private Function CreatePath(PathValue)
	Dim objFSO,uploadpath,strTmpPath
	uploadpath = PathValue & ReplaceTime(Now(), UploadSetting(2))	'以年月创建上传文件夹
	a = Split(uploadpath, "/")
	For i = 0 To (Ubound(a) - 1)
		If Right(PathValue,1)<>"/" Then PathValue = PathValue & "/"
		strTmpPath = strTmpPath & a(i) & "/"
		On Error Resume Next
		Set objFSO = Server.CreateObject(Fso_Sys)
		If objFSO.FolderExists(Server.MapPath(PathValue))=False Then
			objFSO.CreateFolder Server.MapPath(PathValue)
		End If
		If objFSO.FolderExists(Server.MapPath(strTmpPath))=False Then
			objFSO.CreateFolder Server.MapPath(strTmpPath)
		End If
		Set objFSO = Nothing
	Next
	CreatePath = uploadpath
End Function

Function ReplaceTime(s_Time, s_Patt)
	If IsDate(s_Time) = False Then
		ReplaceTime = ""
		Exit Function
	End If
	Dim ret
	ret = s_Patt
	Dim y1, y2, m1, m2, d1, d2, h1, h2, i1, i2, s1, s2
	y2 = CStr(Year(s_Time))
	y1 = Right(y2, 2)
	m1 = CStr(Month(s_Time))
	m2 = Right("0" & m1, 2)
	d1 = CStr(Day(s_Time))
	d2 = Right("0" & d1, 2)
	h1 = CStr(Hour(s_Time))
	h2 = Right("0" & h1, 2)
	i1 = CStr(Minute(s_Time))
	i2 = Right("0" & i1, 2)
	s1 = CStr(Second(s_Time))
	s2 = Right("0" & s1, 2)
	ret = Replace(ret, "{yyyy}", y2, 1, -1, 1)
	ret = Replace(ret, "{yy}", y1, 1, -1, 1)
	ret = Replace(ret, "{mm}", m2, 1, -1, 1)
	ret = Replace(ret, "{m}", m1, 1, -1, 1)
	ret = Replace(ret, "{dd}", d2, 1, -1, 1)
	ret = Replace(ret, "{d}", d1, 1, -1, 1)
	ret = Replace(ret, "{hh}", h2, 1, -1, 1)
	ret = Replace(ret, "{h}", h1, 1, -1, 1)
	ret = Replace(ret, "{ii}", i2, 1, -1, 1)
	ret = Replace(ret, "{i}", i1, 1, -1, 1)
	ret = Replace(ret, "{ss}", s2, 1, -1, 1)
	ret = Replace(ret, "{s}", s1, 1, -1, 1)
	ReplaceTime = ret
End Function

'上传附件非法代码过滤
Function Tmp_Upload(byval t0,byval t1,byval t2)
	On Error Resume Next
	Dim strArray,ii
	strArray=split(UploadSetting(4),"|")
	For ii=0 to ubound(strArray)
		If instr(LCase(LoadFile(t0&t1)),strArray(ii))<>0 Then
			Set Cls = New Cls_FileSystem
			Call Cls.Del_File(t0&t1)
			If Cls.Chk_Exist(t0,0) Then
				If Fso.GetFolder(Server.MapPath(t0)).Files.Count=0 Then
					Cls.Del_Folder t0
				End If
			End If
			Set Cls = Nothing
			If t2 = 0 Then
				Response.Write "{""error"":""非法文件内容！""}"
			Else
				getjson 0,"","","非法文件内容！"
			End If
			Response.End()
		End If
	Next
End Function

Function CheckPurview(byval t0,byval t1)
	If Code_CLng(Session_Get(Session_For&"AdminGroupID")) = 0 Then Exit Function
	Session.Codepage = 65001
	Response.Charset = "utf-8"
	If Code_CLng(Session_Get(Session_For&"AdminGroupID")) <> 0 Then
		sqlGetGroup = "select * from Admin_Group where GroupID=" & Code_CLng(Session_Get(Session_For&"AdminGroupID")) & " and status=1"
		Call Exe_Conn(rsGetGroup,sqlGetGroup,1)
		If rsGetGroup.BOF And rsGetGroup.EOF Then
			rsGetGroup.Close
			Set rsGetGroup = Nothing
			AdminPurview_Group = 0
		Else
			AdminPurview_Group = rsGetGroup("rules")
			If StrLen(AdminPurview_Group) = 0 Then AdminPurview_Group = 0
		End If
	End If
	If instr(","&AdminPurview_Group&",",","&t0&",")<=0 Then
		If t1 = 1 Then
			getjson 0,"","","您无此操作权限。"
		Else
			Response.Write "{""error"":""对不起，您无此操作权限。""}"
		End If
		Call CloseConn()
		Response.End()
	End If
End Function

on error resume next
Session.Contents.Remove("ueditor_asp_listTemplateName")
select case action
	case "config":config
	case "swf":swfdb
	case "template":templatedb
	case "uploadscrawl":Server.Execute("action_upload.asp")
	case "catchimage":Server.Execute("action_crawler.asp")
	case "listimage":Session.Value("ueditor_asp_listTemplateName") = "image":listdb
	case "listfile":Session.Value("ueditor_asp_listTemplateName") = "file":listdb
	case else:editordb
end select
%>